﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KC.DataAccess.Hub;

public partial class _Default : System.Web.UI.Page
{
	public HubDataContext dc;

    protected void Page_Load(object sender, EventArgs e)
    {
		dc = new HubDataContext();
		var pages = from p in dc.Pages
					where p.isEnabled
					orderby p.Created descending
					select p;
		rPages.DataSource = pages;
		rPages.DataBind();
    }

	protected void rPages_ItemDataBound(object sender, RepeaterItemEventArgs e)
	{
		if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
			return;
		KC.DataAccess.Hub.Page p = (KC.DataAccess.Hub.Page)e.Item.DataItem;
		
		HyperLink hlPage = (HyperLink)e.Item.FindControl("hlPage");
		hlPage.Text = Server.HtmlEncode(p.Title);
		hlPage.NavigateUrl = "http://hub.kconnolly.net/page.aspx?title=" + p.FriendlyName;

		Label lblDesc = (Label)e.Item.FindControl("lblDesc");
		lblDesc.Text = p.Description;
	}
}